package com.myhome.money.cloud.gateway;

import com.myhome.money.cloud.gateway.config.AuthGatewayFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

/**
 * @author 许路路
 */
@SpringBootApplication
public class CloudGatewayApplication {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                // basic proxy
                .route(r -> r.path("/baidu/**")
                        .uri("http://localhost:8080/"))
                .route(r -> r.path("/dubbo/**").
                        filters(f -> f.filter(new AuthGatewayFilter())).uri("http://localhost:8080/"))
                .build();
    }

    public static void main(String[] args) {
        SpringApplication.run(CloudGatewayApplication.class, args);
    }

}
